import request from '../utils/request';
import { coachItemData } from './coach';
import { licenceItemData } from './licence';
import { progressItemData } from './process';
import { studentItemData } from './student';

const url = 'http://localhost:8080/application';

export interface applicationItemData 
{
    applicationId : number;
    applicationTime  : Date ;
    applicationPreference : string ;
    applicationFinished : string ;

    progressId: number;
    coachId: number;
    studentId: number;
    licenceId: number;

    progress? : progressItemData;
    coach : coachItemData;
    student? : studentItemData;
    licence? : licenceItemData;
}

export const getApplicationByStudentId = (studentId : number) => {
    return request({
        url: url+'/getAllApplicationByID/'+studentId,
        method: 'get',
    });
};

export const updateApplication = (application : applicationItemData) => {
    return request({
        url: url+`/updateApplication`,
        method: 'post',
        data : application,
    });
};

export const filterApplication = (application : applicationItemData) => {
    return request({
        url: url+`/filterApplication`,
        method: 'post',
        data : application,
    });
};

export const addApplication = (application : applicationItemData, studentId : number) => {
    return request({
        url: url+`/addApplication?studentAccountId=${studentId}`,
        method: 'post',
        data : application,
    });
};

export const deleteApplication = (applicationId : string) => {
    return request({
        url: url+`/deleteApplication/`+applicationId,
        method: 'delete',
    });
};

export const getAllApplication = () => {
    return request({
        url: url+`/getAllApplication`,
        method: 'get',
    });
};

export const getStudentApplication = (studentId : any) => {
    return request({
        url: url+`/getApplication/${studentId}`,
        method: 'get',
    });
};